//
//  NavViewController.swift
//  NavPushAni
//
//  Created by 李煜 on 2022/8/16.
//

import UIKit

class NavViewController: UINavigationController {
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    setupNaviBarStyle()
    
    
  }
  
  private func setupNaviBarStyle(){
    let naviBar = UINavigationBar.appearance(whenContainedInInstancesOf: [NavViewController.self])
    naviBar.shadowImage = UIImage()
    naviBar.barStyle = .default
    naviBar.isTranslucent = false

    let bgImage = UIImage.image(from: .orange)
    //设置背景颜色
    naviBar.setBackgroundImage(bgImage, for: .default)
    //设置字体颜色
    let textAttrs: [NSAttributedString.Key : Any] = [.foregroundColor : UIColor.black]
    naviBar.titleTextAttributes = textAttrs
    
    //      适配iOS13
    if #available(iOS 13, *) {
      let naviBarAppearance = UINavigationBarAppearance()
      naviBarAppearance.backgroundImage = bgImage
      naviBarAppearance.titleTextAttributes = textAttrs
      
      //去掉半透明
      naviBarAppearance.backgroundEffect = nil
      //去除阴影线
      naviBarAppearance.shadowColor = .clear
      naviBar.scrollEdgeAppearance = naviBarAppearance
      naviBar.standardAppearance = naviBarAppearance
      naviBar.compactAppearance = naviBarAppearance

//      UITabBarAppearance
    }
  }
  
}
